﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Aliyeye.Car.Net.UI.Controls
{
    public partial class LargeIconButton : SmallIconButton
    {
        public LargeIconButton()
        {
            InitializeComponent();

            this.Size = new Size(61, 61);
        }

        protected override SmallIconButton.IconTextLayoutInfo ComputeIconTextPosition(Graphics g)
        {
            IconTextLayoutInfo ret = new IconTextLayoutInfo()
            {
                X = 0,
                Y = 0,
                TextMarginLeft = 0,
                TextMarginTop = 0
            };

            SizeF total = new SizeF();
            SizeF textSize = g.MeasureString(this.Text, this.Font);

            total.Width = textSize.Width;
            total.Height = textSize.Height;

            int gap = 0;

            if (this.Icon != null)
            {
                ret.TextMarginLeft = (this.Icon.Width - (int)total.Width) / 2;
                ret.TextMarginTop = this.Icon.Height + gap;
                total.Width = this.Icon.Width;
                total.Height += this.Icon.Height + gap;
            }


            switch (this.TextAlign)
            {
                case ContentAlignment.MiddleCenter:
                    ret.X = this.Padding.Left+(this.Width - this.Padding.Left - this.Padding.Right - (int)total.Width) / 2;
                    ret.Y = this.Padding.Top+(this.Height - this.Padding.Top - this.Padding.Bottom - (int)total.Height) / 2;
                    break;

                case ContentAlignment.MiddleLeft:
                    ret.X = this.Padding.Left;
                    ret.Y = this.Padding.Top+(this.Height - this.Padding.Top - this.Padding.Bottom - (int)total.Height) / 2;
                    break;
                case ContentAlignment.TopLeft:
                    ret.X = this.Padding.Left;
                    ret.Y = this.Padding.Top;
                    break;
                default:
                    break;
            }

            return ret;
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
        }
    }
}
